<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="*|/"><xsl:apply-templates/></xsl:template>

<xsl:template match="text()|@*"><xsl:value-of select="."/></xsl:template>

<xsl:template match='nbsp' name='nbsp'>
<xsl:text disable-output-escaping='yes'>&amp;nbsp;</xsl:text>
</xsl:template>

<xsl:template name="monthName">
 <xsl:param name="month"/>
 <xsl:choose>
   <xsl:when test="$month=1">Gennaio</xsl:when>
   <xsl:when test="$month=2">Febbraio</xsl:when>
   <xsl:when test="$month=3">Marzo</xsl:when>
   <xsl:when test="$month=4">Aprile</xsl:when>
   <xsl:when test="$month=5">Maggio</xsl:when>
   <xsl:when test="$month=6">Giugno</xsl:when>
   <xsl:when test="$month=7">Luglio</xsl:when>
   <xsl:when test="$month=8">Agosto</xsl:when>
   <xsl:when test="$month=9">Settembre</xsl:when>
   <xsl:when test="$month=10">Ottobre</xsl:when>
   <xsl:when test="$month=11">Novembre</xsl:when>
   <xsl:when test="$month=12">Dicembre</xsl:when>
   <xsl:otherwise>
     <xsl:value-of select="$month"/>
   </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:template match="activities">

<table class="body" style="background-color: transparent;" border="0" cellspacing="0" cellpadding="0" width="100%">
<tr><td class="CDBhead" width="1px">&#160;</td>
	<td class="CDBhead"><b><xsl:value-of select="@place"/></b> (<a href="/activitiesCities.aspx">Cambia citta'</a>)</td>
			<xsl:for-each select="wday">
	<td class="CDBhead" style="font-size:10px;" align="center">
		<xsl:value-of select="@shortname"/><br/>
		<xsl:value-of select="@dayOfMonth"/>
	</td>
			</xsl:for-each>
	<td class="CDBhead" width="1px">&#160;</td>
</tr>

<xsl:for-each select="week">
<tr class="CDBf10">
	<td class="CDB"></td>
	<xsl:choose>
		<xsl:when test="(floor( @status div 2 ) mod 2 )">
		<td class="CDBf10" align="left" style="padding:2px;" height="22px" valign="middle">
			<a href="/activities/activityShow.aspx?activityId={@activityId}" class="body_10px_red"><img border="0" src="/imgs/banner/{@banner}"/></a>
		</td>
		</xsl:when>
		<xsl:when test="@bold=1">
		<td class="CDBf10" align="left" height="22px" valign="middle">
			<b><a href="/activities/activityShow.aspx?activityId={@activityId}" class="body_10px_red"><xsl:value-of select="@title"/></a></b>
		</td>
		</xsl:when>
		<xsl:otherwise>
		<td class="CDBf10" align="left">
			<a href="/activities/activityShow.aspx?activityId={@activityId}" class="body_10px_red"><xsl:value-of select="@title"/></a>
		</td>
		</xsl:otherwise>
	</xsl:choose>
	<xsl:variable name="activityId"><xsl:value-of select="@activityId"/></xsl:variable>
	<xsl:for-each select="/activities/wday">
	<xsl:variable name="dayOfYear"><xsl:value-of select="@dayOfYear"/></xsl:variable>
	<xsl:variable name="hits">
		<xsl:value-of select="/activities/weekDays[@day=$dayOfYear and @activityId=$activityId]/@hit"/>
	</xsl:variable>
			<xsl:choose>
				<xsl:when test="$hits &gt; 50">
<td class="CDBf10c" align="center">
<xsl:value-of select="$hits"/>
</td>
				</xsl:when>
				<xsl:when test="$hits &gt; 20 and $hits &lt;= 50">
<td class="CDBf10c" align="center">
<xsl:value-of select="$hits"/>
</td>
				</xsl:when>
				<xsl:when test="$hits &gt; 0 and $hits &lt;= 20">
<td class="CDBf10c" align="center">
<xsl:value-of select="$hits"/>
</td>
				</xsl:when>
				<xsl:otherwise>
<td class="CDBf10c">
&#160;
</td>
				</xsl:otherwise>
			</xsl:choose>
	</xsl:for-each>
	<td class="CDB"></td>
</tr>
</xsl:for-each>

<tr><td colspan="10" class="body" align="right">
<a class="segue" href="/allActivities.aspx?week=1">...segue</a>
</td>
</tr>
<tr height="10px"><td colspan="9"></td></tr>
<xsl:for-each select="future">
<tr>
	<td class="CDB"></td>
	<xsl:choose>
		<xsl:when test="(floor( @status div 2 ) mod 2 )">
		<td class="CDBf10" align="left"  style="padding:2px;" height="22px" valign="middle">
			<a href="/activities/activityShow.aspx?activityId={@activityId}" class="body_10px_red"><img border="0" src="/imgs/banner/{@banner}"/></a>
		</td>
		</xsl:when>
		<xsl:when test="@bold=1">
		<td class="CDBf10" align="left" height="22px" valign="middle">
			<b><a href="/activities/activityShow.aspx?activityId={@activityId}" class="body_10px_red"><xsl:value-of select="@title"/></a></b>
		</td>
		</xsl:when>
		<xsl:otherwise>
		<td class="CDBf10" align="left">
			<a href="/activities/activityShow.aspx?activityId={@activityId}" class="body_10px_red"><xsl:value-of select="@title"/></a>
		</td>
		</xsl:otherwise>
	</xsl:choose>
	<td class="CDBf10c" colspan="5" align="center">
		<font class="body_10px"><xsl:value-of select="@dd"/>&#160;
		<xsl:call-template name="monthName">
		<xsl:with-param name="month" select="@mm"/>
		</xsl:call-template>&#160;
		<xsl:value-of select="@aaaa"/></font>
		</td>
	<td class="CDBf9c" colspan="2" align="center">
		<xsl:value-of select="@howMany"/>
	</td>
</tr>
</xsl:for-each>
<tr>
	<td colspan="10" align="right">
	<a href="/allActivities.aspx?future=1" class="segue">...segue</a>
	</td>
</tr>
<tr><td colspan="10" class="CDB" align="center"><img src="/imgs/white_sp.gif"/></td></tr>
<tr>
	<td colspan="10" class="body" align="center">
	Clicka sul nome dell'attivita' per saperne di piu' e parteciparvi!
	</td>
</tr>
<tr>
	<td colspan="10" class="body_10px" align="center">
	(E' possibile creare attivita' per ogni citta' capoluogo di provincia, <a href="/activities/activityCreate.aspx">clicca qui!</a>)
	</td>
</tr>
<tr><td colspan="10" class="CDB" align="center"><img src="/imgs/white_sp.gif"/></td></tr>
<tr height="5px"><td colspan="10"></td></tr>
</table>

</xsl:template>

</xsl:stylesheet>